package com.czk.interfaces;

import org.springframework.stereotype.Component;

import java.util.Objects;

/**
 * @Author:ChenZhangKun
 * @Date: 2021/5/17 9:59
 */
@Component
public class ITableSharedStrategyId implements ITableSharedStrategy {
    @Override
    public String generateTableName(String prefix, Object value) {
        // 验证前缀
        verificationTableNamePrefix(prefix);
        // 验证value
        if (value == null|| Objects.equals("",value)) {
            throw new RuntimeException("value不能为空");
        }
        // 生成表明
        long l = Long.parseLong(value.toString());
        return prefix + "_" + (l % 2);
    }
}
